#include <iostream>
#include "BinaryTree.h"

class Solution
{
  public:
	TreeNode *invertTree(TreeNode *root)
	{
		if (root == NULL)
			return NULL;
		invertTree(root->left);
		invertTree(root->right);
		swap(root->left, root->right);
		return root;
	}
};

using namespace std;
int main()
{
	int arr[] = {4, 7, 2, 9, 0, 0, 6, 0, 0, 2, 3, 0, 0, 1, 0, 0};
	int n = sizeof(arr) / sizeof(arr[0]);
	TreeNode *tree = createBinaryTree(arr, n);
	preorderPrint(tree);
	cout << endl;
	tree = Solution().invertTree(tree);
	preorderPrint(tree);
	cout << endl;
	return 0;
}
